var codes ="";
var houseInfo="";//房间信息
var familyId="";//住户ID
var faultState=1;
$(function(e){
	receiveData();
	dataInit();
	
})

function dataInit(){
	familyId = $.req("creatId");
	getRepairRecord()
	eventInit();
}


function eventInit(){
	
	//跳转报修页面
	$('body').on('click', '#search1', function(e){
		location.href = "../../html/wechat_repair/wechat_repair.html";
	});
}


function getRepairRecord(){
	var params = {
		faultState : faultState,
		id : familyId
	}
	
	AjaxPostUtil.request({url : path+"9be207b53bdd40c9a1df37b0eec80c90", params : params, type : 'json', callback : function(json){
		
		if(json.returnCode == 0){
			console.log(json);
			//待处理
			Handlebars.registerHelper("compare1", function(v1, v2, options){
				console.log(json);
				if(v1 == 1 && v2==1){
					return options.fn(this);
				}else if(v1==1 && v2==0){
					return options.inverse(this);
				}
				if(v1==2 && v2==1){
					return options.fn(this);
				}else if(v1==2 && v2==0){
					return options.inverse(this);
				}
			});
			
			var source = $("#repairState").html();
			var template = Handlebars.compile(source);
			$("#repairDiv").html(template(json));
			
			//处理中
			Handlebars.registerHelper("compare1", function(v1, v2, options){
				console.log(json);
				if(v1 == 1 && v2==2){
					return options.fn(this);
				}else if(v1==1 && v2==0){
					return options.inverse(this);
				}
				if(v1==2 && v2==2){
					return options.fn(this);
				}else if(v1==2 && v2==0){
					return options.inverse(this);
				}
			});
			
			var source = $("#repairState").html();
			var template = Handlebars.compile(source);
			$("#repairDiv2").html(template(json));
			
			//已处理
			Handlebars.registerHelper("compare1", function(v1, v2, options){
				if(v1 == 1 && v2==3){
					return options.fn(this);
				}else if(v1==1 && v2==0){
					return options.inverse(this);
				}
				if(v1==2 && v2==3){
					return options.fn(this);
				}else if(v1==2 && v2==0){
					return options.inverse(this);
				}
			});
			
			var source = $("#repairState").html();
			var template = Handlebars.compile(source);
			$("#repairDiv3").html(template(json));
			
		}else{
			swal({ title : "错误", text : json.returnMessage, type : "error" }); 
		}
		
	}});
	
	
	
}


